package com.dao.impl;

import com.dao.EmpDao;
import com.entity.Employee;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class EmpDaoImpl extends BaseDao implements EmpDao {
    @Override
    public String getNameById(Integer id) {

        QueryRunner qr = getQueryRunner();
        String sql = "select emp_name as empName from employee where id = ?";
        BeanHandler<Employee> handler = new BeanHandler<>(Employee.class);
        Employee employee = null;
        try {
            employee = qr.query(sql, handler, id);
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return employee.getEmpName();

    }


}
